/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.fsiebert.polytech.db.mediatheque.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Florent
 */
@Entity
@Table(name = "LieuResidence")
@NamedQueries({
    @NamedQuery(name = "LieuResidence.findAll", query = "SELECT l FROM LieuResidence l"),
    @NamedQuery(name = "LieuResidence.findByCodePostal", query = "SELECT l FROM LieuResidence l WHERE l.codePostal = :codePostal"),
    @NamedQuery(name = "LieuResidence.findByLibelle", query = "SELECT l FROM LieuResidence l WHERE l.libelle = :libelle"),
    @NamedQuery(name = "LieuResidence.findByCoefMontantAdhesionLieudepend", query = "SELECT l FROM LieuResidence l WHERE l.coefMontantAdhesionLieudepend = :coefMontantAdhesionLieudepend"),
    @NamedQuery(name = "LieuResidence.findByIdLieuResidence", query = "SELECT l FROM LieuResidence l WHERE l.idLieuResidence = :idLieuResidence")})
public class LieuResidence implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 5)
    @Column(name = "CodePostal", nullable = false, length = 5)
    private String codePostal;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "Libelle", nullable = false, length = 255)
    private String libelle;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CoefMontantAdhesionLieudepend", nullable = false)
    private float coefMontantAdhesionLieudepend;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idLieuResidence", nullable = false)
    private Integer idLieuResidence;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "lieuResidence")
    private List<Adherent> adherentList;

    public LieuResidence() {
    }

    public LieuResidence(Integer idLieuResidence) {
        this.idLieuResidence = idLieuResidence;
    }

    public LieuResidence(Integer idLieuResidence, String codePostal, String libelle, float coefMontantAdhesionLieudepend) {
        this.idLieuResidence = idLieuResidence;
        this.codePostal = codePostal;
        this.libelle = libelle;
        this.coefMontantAdhesionLieudepend = coefMontantAdhesionLieudepend;
    }

    public String getCodePostal() {
        return codePostal;
    }

    public void setCodePostal(String codePostal) {
        this.codePostal = codePostal;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    public float getCoefMontantAdhesionLieudepend() {
        return coefMontantAdhesionLieudepend;
    }

    public void setCoefMontantAdhesionLieudepend(float coefMontantAdhesionLieudepend) {
        this.coefMontantAdhesionLieudepend = coefMontantAdhesionLieudepend;
    }

    public Integer getIdLieuResidence() {
        return idLieuResidence;
    }

    public void setIdLieuResidence(Integer idLieuResidence) {
        this.idLieuResidence = idLieuResidence;
    }

    public List<Adherent> getAdherentList() {
        return adherentList;
    }

    public void setAdherentList(List<Adherent> adherentList) {
        this.adherentList = adherentList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idLieuResidence != null ? idLieuResidence.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LieuResidence)) {
            return false;
        }
        LieuResidence other = (LieuResidence) object;
        if ((this.idLieuResidence == null && other.idLieuResidence != null) || (this.idLieuResidence != null && !this.idLieuResidence.equals(other.idLieuResidence))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        //return "eu.fsiebert.polytech.db.mediatheque.entity.LieuResidence[ idLieuResidence=" + idLieuResidence + " ]";
        return codePostal + " " + libelle;
    }
    
}
